package com.bringway.p2p.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.sf.json.JSONObject;

import com.bringway.framework.excel.ExcelSheet;
import com.bringway.global.dao.SysAttechmentDao;
import com.bringway.p2p.dao.CzDao;
import com.bringway.p2p.service.CzService;

/**
 * 
 * @author zhai
 * @version 创建时间：2015年12月15日 上午9:34:42
 * @功能：充值结果界面
 */

@Service
@Transactional
public class CzServiceImpl implements CzService {
	
	@Autowired
	private CzDao czDao;
	
	
	
	@Override
	public List<Map<String, Object>> queryCzList(JSONObject params) {
		return czDao.queryCzList(params);
	}

	@Override
	public int getCzCount(JSONObject params) {
		return czDao.getCzCount(params);
	}

	@Override
	public List<ExcelSheet> exportCzData(List<Map<String, Object>> czList) {
		 // 生成导入到EXECL的LIST
		List<ExcelSheet> sheetList = new ArrayList<ExcelSheet>();
		int headerCount = 5;
		// 点击汇总导出
		List<String[]> bodyList = new ArrayList<String[]>();
		for (int i = 0; i < czList.size(); i++) {
			String[] contents = new String[22];
			JSONObject obj = new JSONObject();
			obj = JSONObject.fromObject(czList.get(i));
			contents[0] = (i + 1)+"";//序号
			contents[1] = obj.optString("DDH");
			contents[2] = obj.optString("SHH");
			contents[3] = obj.optString("CZJE");
			contents[4] = obj.optString("CZSJ");
			contents[4] = obj.optString("CZJG");
			bodyList.add(contents);
		}
		ExcelSheet excelSheet = new ExcelSheet();
		excelSheet.setBodyList(bodyList);
		excelSheet.setSheetName("service层实现导出Excel");
		excelSheet.setFromRow(headerCount);
		sheetList.add(excelSheet);
		return sheetList;
	}

	@Override
	public String geCzjeSum(JSONObject params) {
		return czDao.geCzjeSum(params);
	}


}
